<?php
/*
Copyright (C) 2009 de Flotte Maxence

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
?>
<?php
//Puzzle:: permet d'incure un puzzle dans un puzzle
class std_Puzzle extends Bout {
  private $puzzle;

  function setPuzzle($puzzle) {
    $this->puzzle = $puzzle;
  }

  function build() {
  $MySql = $GLOBALS['MySql'];
  //On charge le puzzle
    $query = $MySql->query('SELECT * FROM '.$GLOBALS['prefix'].'puzzle Where id='.$this->puzzle);
    $_puzzle = $query->fetch_assoc();
    //Si il y a une réponce
      if($_puzzle != null) {
	$return = '
  <script type="text/javascript">
  <!--
  function '.$this->name.'Reload() {
	  LoadPage(\'LoadPuzzle.php?puzzle='.$this->puzzle.'\',\''.$this->name.'\');
  }
  //-->
  </script>
  <div id="'.$this->name.'">'."\n  ".readPuzzle($_puzzle['ZzS'],true).'  </div>'."\n";
	//On oublie pas de reouvrir la session fermé par le read puzzle
	$GLOBALS['MySql'] = new mysqli($GLOBALS['Serveur'], $GLOBALS['Login'], $GLOBALS['PassWord'], $GLOBALS['DB']);
	return $return;
      }
      else
	return null;
  }
}
?>